home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / clocks / attall / settime.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-03-29  |  23.1 KB  |  819 lines

  1. VERSION 2.00
  2. Begin Form SetTimeForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Set Time"
  6.    ClientHeight    =   1305
  7.    ClientLeft      =   5100
  8.    ClientTop       =   3405
  9.    ClientWidth     =   3645
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    Height          =   1740
  13.    Left            =   5025
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   1305
  18.    ScaleWidth      =   3645
  19.    Top             =   3045
  20.    Width           =   3795
  21.    Begin CommandButton Command1 
  22.       Cancel          =   -1  'True
  23.       Caption         =   "Check Now"
  24.       Height          =   360
  25.       Index           =   2
  26.       Left            =   2268
  27.       TabIndex        =   23
  28.       TabStop         =   0   'False
  29.       Top             =   2640
  30.       Width           =   1155
  31.    End
  32.    Begin TextBox Text2 
  33.       BackColor       =   &H00C0C0C0&
  34.       BorderStyle     =   0  'None
  35.       Height          =   192
  36.       Left            =   240
  37.       MultiLine       =   -1  'True
  38.       TabIndex        =   27
  39.       TabStop         =   0   'False
  40.       Text            =   "300"
  41.       Top             =   2760
  42.       Width           =   350
  43.    End
  44.    Begin SSFrame Frame3D1 
  45.       Caption         =   "Time Server Address"
  46.       Font3D          =   0  'None
  47.       ForeColor       =   &H00000000&
  48.       Height          =   624
  49.       Index           =   2
  50.       Left            =   240
  51.       TabIndex        =   22
  52.       Top             =   1800
  53.       Width           =   3132
  54.       Begin TextBox Text1 
  55.          BackColor       =   &H00C0C0C0&
  56.          BorderStyle     =   0  'None
  57.          Height          =   252
  58.          Left            =   120
  59.          TabIndex        =   25
  60.          TabStop         =   0   'False
  61.          Text            =   "panix.com"
  62.          Top             =   300
  63.          Width           =   2844
  64.       End
  65.    End
  66.    Begin SSCheck Check3D1 
  67.       Caption         =   "Use Time Server"
  68.       Font3D          =   0  'None
  69.       Height          =   312
  70.       Left            =   240
  71.       TabIndex        =   21
  72.       TabStop         =   0   'False
  73.       Top             =   1440
  74.       Width           =   1692
  75.    End
  76.    Begin SSCommand Command3D1 
  77.       Font3D          =   0  'None
  78.       Height          =   465
  79.       Left            =   165
  80.       Picture         =   SETTIME.FRX:0000
  81.       TabIndex        =   18
  82.       Top             =   720
  83.       Width           =   540
  84.    End
  85.    Begin CommandButton Command1 
  86.       Caption         =   "Cancel"
  87.       Height          =   360
  88.       Index           =   1
  89.       Left            =   2265
  90.       TabIndex        =   20
  91.       Top             =   765
  92.       Width           =   1155
  93.    End
  94.    Begin CommandButton Command1 
  95.       Caption         =   "Set"
  96.       Default         =   -1  'True
  97.       Height          =   360
  98.       Index           =   0
  99.       Left            =   885
  100.       TabIndex        =   19
  101.       Top             =   765
  102.       Width           =   1155
  103.    End
  104.    Begin PictureBox SpinButton 
  105.       AutoSize        =   -1  'True
  106.       BackColor       =   &H00C0C0C0&
  107.       Height          =   360
  108.       Index           =   1
  109.       Left            =   3255
  110.       ScaleHeight     =   330
  111.       ScaleWidth      =   135
  112.       TabIndex        =   17
  113.       TabStop         =   0   'False
  114.       Top             =   240
  115.       Width           =   165
  116.    End
  117.    Begin SSFrame Frame3D1 
  118.       Font3D          =   0  'None
  119.       ForeColor       =   &H00000000&
  120.       Height          =   444
  121.       Index           =   1
  122.       Left            =   1830
  123.       TabIndex        =   11
  124.       Top             =   156
  125.       Width           =   1395
  126.       Begin TextBox tYear 
  127.          BackColor       =   &H00C0C0C0&
  128.          BorderStyle     =   0  'None
  129.          Height          =   225
  130.          Left            =   780
  131.          MaxLength       =   4
  132.          TabIndex        =   14
  133.          Tag             =   "y"
  134.          Text            =   "1955"
  135.          Top             =   150
  136.          Width           =   480
  137.       End
  138.       Begin TextBox tDay 
  139.          BackColor       =   &H00C0C0C0&
  140.          BorderStyle     =   0  'None
  141.          Height          =   225
  142.          Left            =   450
  143.          MaxLength       =   2
  144.          TabIndex        =   13
  145.          Tag             =   "d"
  146.          Text            =   "17"
  147.          Top             =   150
  148.          Width           =   240
  149.       End
  150.       Begin TextBox tMonth 
  151.          Alignment       =   1  'Right Justify
  152.          BackColor       =   &H00C0C0C0&
  153.          BorderStyle     =   0  'None
  154.          Height          =   225
  155.          Left            =   120
  156.          MaxLength       =   2
  157.          TabIndex        =   12
  158.          Tag             =   "n"
  159.          Text            =   "09"
  160.          Top             =   150
  161.          Width           =   240
  162.       End
  163.       Begin Label Label1 
  164.          Alignment       =   2  'Center
  165.          BackColor       =   &H00C0C0C0&
  166.          Caption         =   "/"
  167.          Height          =   225
  168.          Index           =   3
  169.          Left            =   690
  170.          TabIndex        =   16
  171.          Top             =   150
  172.          Width           =   105
  173.       End
  174.       Begin Label Label1 
  175.          Alignment       =   2  'Center
  176.          BackColor       =   &H00C0C0C0&
  177.          Caption         =   "/"
  178.          Height          =   225
  179.          Index           =   2
  180.          Left            =   345
  181.          TabIndex        =   15
  182.          Top             =   150
  183.          Width           =   105
  184.       End
  185.    End
  186.    Begin PictureBox SpinButton 
  187.       AutoSize        =   -1  'True
  188.       BackColor       =   &H00C0C0C0&
  189.       Height          =   360
  190.       Index           =   0
  191.       Left            =   1590
  192.       ScaleHeight     =   330
  193.       ScaleWidth      =   135
  194.       TabIndex        =   7
  195.       TabStop         =   0   'False
  196.       Top             =   240
  197.       Width           =   165
  198.    End
  199.    Begin PictureBox N 
  200.       AutoSize        =   -1  'True
  201.       Height          =   360
  202.       Left            =   2736
  203.       Picture         =   SETTIME.FRX:016A
  204.       ScaleHeight     =   330
  205.       ScaleWidth      =   135
  206.       TabIndex        =   6
  207.       TabStop         =   0   'False
  208.       Top             =   3432
  209.       Visible         =   0   'False
  210.       Width           =   165
  211.    End
  212.    Begin PictureBox U 
  213.       AutoSize        =   -1  'True
  214.       Height          =   360
  215.       Left            =   2940
  216.       Picture         =   SETTIME.FRX:0294
  217.       ScaleHeight     =   330
  218.       ScaleWidth      =   135
  219.       TabIndex        =   5
  220.       TabStop         =   0   'False
  221.       Top             =   3420
  222.       Visible         =   0   'False
  223.       Width           =   165
  224.    End
  225.    Begin PictureBox D 
  226.       AutoSize        =   -1  'True
  227.       Height          =   360
  228.       Left            =   3168
  229.       Picture         =   SETTIME.FRX:03BE
  230.       ScaleHeight     =   330
  231.       ScaleWidth      =   135
  232.       TabIndex        =   0
  233.       TabStop         =   0   'False
  234.       Top             =   3420
  235.       Visible         =   0   'False
  236.       Width           =   165
  237.    End
  238.    Begin SSFrame Frame3D1 
  239.       Font3D          =   0  'None
  240.       ForeColor       =   &H00000000&
  241.       Height          =   444
  242.       Index           =   0
  243.       Left            =   168
  244.       TabIndex        =   8
  245.       Top             =   156
  246.       Width           =   1392
  247.       Begin TextBox tHour 
  248.          Alignment       =   1  'Right Justify
  249.          BackColor       =   &H00C0C0C0&
  250.          BorderStyle     =   0  'None
  251.          Height          =   225
  252.          Left            =   120
  253.          MaxLength       =   2
  254.          MultiLine       =   -1  'True
  255.          TabIndex        =   1
  256.          Tag             =   "h"
  257.          Text            =   "12"
  258.          Top             =   150
  259.          Width           =   240
  260.       End
  261.       Begin TextBox tMinute 
  262.          BackColor       =   &H00C0C0C0&
  263.          BorderStyle     =   0  'None
  264.          Height          =   225
  265.          Left            =   456
  266.          MaxLength       =   2
  267.          TabIndex        =   2
  268.          Tag             =   "m"
  269.          Text            =   "00"
  270.          Top             =   150
  271.          Width           =   240
  272.       End
  273.       Begin TextBox tAMPM 
  274.          BackColor       =   &H00C0C0C0&
  275.          BorderStyle     =   0  'None
  276.          Height          =   225
  277.          Left            =   1020
  278.          TabIndex        =   4
  279.          Tag             =   "a"
  280.          Text            =   "am"
  281.          Top             =   150
  282.          Width           =   285
  283.       End
  284.       Begin TextBox tSecond 
  285.          BackColor       =   &H00C0C0C0&
  286.          BorderStyle     =   0  'None
  287.          Height          =   225
  288.          Left            =   780
  289.          MaxLength       =   2
  290.          TabIndex        =   3
  291.          Tag             =   "s"
  292.          Text            =   "00"
  293.          Top             =   150
  294.          Width           =   240
  295.       End
  296.       Begin Label Label1 
  297.          Alignment       =   2  'Center
  298.          BackColor       =   &H00C0C0C0&
  299.          Caption         =   ":"
  300.          Height          =   225
  301.          Index           =   0
  302.          Left            =   345
  303.          TabIndex        =   10
  304.          Top             =   150
  305.          Width           =   105
  306.       End
  307.       Begin Label Label1 
  308.          Alignment       =   2  'Center
  309.          BackColor       =   &H00C0C0C0&
  310.          Caption         =   ":"
  311.          Height          =   225
  312.          Index           =   1
  313.          Left            =   675
  314.          TabIndex        =   9
  315.          Top             =   150
  316.          Width           =   105
  317.       End
  318.    End
  319.    Begin Label Label2 
  320.       BackStyle       =   0  'Transparent
  321.       Caption         =   "minutes."
  322.       ForeColor       =   &H00000000&
  323.       Height          =   252
  324.       Index           =   1
  325.       Left            =   600
  326.       TabIndex        =   24
  327.       Top             =   2760
  328.       Width           =   792
  329.    End
  330.    Begin Label Label2 
  331.       BackStyle       =   0  'Transparent
  332.       Caption         =   "Check every"
  333.       ForeColor       =   &H00000000&
  334.       Height          =   252
  335.       Index           =   0
  336.       Left            =   240
  337.       TabIndex        =   26
  338.       Top             =   2580
  339.       Width           =   1128
  340.    End
  341.    Begin Line Line1 
  342.       BorderColor     =   &H00FFFFFF&
  343.       Index           =   1
  344.       X1              =   252
  345.       X2              =   3372
  346.       Y1              =   1332
  347.       Y2              =   1332
  348.    End
  349.    Begin Line Line1 
  350.       BorderColor     =   &H00808080&
  351.       Index           =   0
  352.       X1              =   240
  353.       X2              =   3360
  354.       Y1              =   1320
  355.       Y2              =   1320
  356.    End
  357. Option Explicit
  358. DefInt A-Z
  359. Dim LastY As Single
  360. Dim Active As String
  361. Dim LastDirection As String
  362. Dim tVal As Integer
  363. ' Jeffrey M. Richter's Spin Button Control from Windows 3: A Developer's Guide
  364. ' Adapted for Visual Basic by Costas Kitsos with Mr. Richter's kind permission
  365. ' Windows API functions used by the Spin Button Control
  366. Declare Function GetTickCount Lib "User" () As Long
  367. Declare Function GetAsyncKeyState Lib "User" (ByVal vKey As Integer) As Integer
  368. Sub Command1_Click (Index As Integer)
  369. If Index = 0 Then
  370.   Time = tHour.Text + ":" + tMinute.Text + ":" + tSecond.Text + UCase$(tAMPM.Text)
  371.   Date = DateSerial(tYear.Text, tMonth.Text, tDay.Text)
  372.   LastTime = 0
  373.   LastHour = Val(Format$(Time, "hh"))
  374.   LastQuarter = Val(Format$(Time, "nn")) \ 15
  375.   Unload SetTimeForm
  376. End If
  377. If Index = 1 Then
  378.   LastTime = 0
  379.   Unload SetTimeForm
  380. End If
  381. End Sub
  382. Sub Command3D1_Click ()
  383. AtomicTimeWasSet = False
  384. Atomic.Show 1
  385. Unload Atomic
  386. If AtomicTimeWasSet Then
  387.    Unload SetTimeForm
  388. End If
  389. End Sub
  390. Sub FlipFlopTAMPM ()
  391.          If tAMPM.Text = "am" Then
  392.             tAMPM.Text = "pm"
  393.          Else
  394.             tAMPM.Text = "am"
  395.          End If
  396. End Sub
  397. Sub Form_GotFocus ()
  398.     tHour.SetFocus
  399.     DoEvents
  400. End Sub
  401. Sub Form_Load ()
  402. SetTimeForm.Left = Settings.Left + (Settings.Width / 2) - (SetTimeForm.Width / 2)
  403. SetTimeForm.Top = Settings.Top + (Settings.Height / 2) - (SetTimeForm.Height / 2)
  404. Dim Instant As Double
  405. Dim InitialHeight As Integer
  406.     InitialHeight = SpinButton(0).Height
  407.     SpinButton(0).Picture = N.Picture       'Set to the Normal Spin Button
  408.     SpinButton(0).Top = SpinButton(0).Top + (InitialHeight - SpinButton(0).Height) / 2
  409.     SpinButton(1).Picture = N.Picture       'Set to the Normal Spin Button
  410.     SpinButton(1).Top = SpinButton(1).Top + (InitialHeight - SpinButton(1).Height) / 2
  411.     Instant = Now
  412.     If Hour(Instant) = 0 Then
  413.        tHour.Text = "12"
  414.        tAMPM.Text = "am"
  415.     End If
  416.     If Hour(Instant) >= 1 And Hour(Instant) <= 11 Then
  417.        tHour.Text = Format$(Hour(Instant))
  418.        tAMPM.Text = "am"
  419.     End If
  420.     If Hour(Instant) = 12 Then
  421.        tHour.Text = Format$(Hour(Instant))
  422.        tAMPM.Text = "pm"
  423.     End If
  424.     If Hour(Instant) >= 13 And Hour(Instant) <= 23 Then
  425.        tHour.Text = Format$(Hour(Instant) - 12)
  426.        tAMPM.Text = "pm"
  427.     End If
  428.     tMinute.Text = Format$(Minute(Instant), "00")
  429.     tSecond.Text = Format$(Second(Instant), "00")
  430.     tMonth.Text = Format$(Month(Instant), "00")
  431.     tDay.Text = Format$(Day(Instant), "00")
  432.     tYear.Text = Format$(Year(Instant), "0000")
  433.     'SetTimeFOrm.Show
  434.     'DoEvents
  435. End Sub
  436. Sub MoveDown (c As Control)
  437. Dim CurVal As Integer
  438. CurVal% = Val(c.Text)
  439. Select Case c.Tag
  440.    Case "h"
  441.       If CurVal% = 12 Then
  442.          FlipFlopTAMPM
  443.       End If
  444.       If CurVal% = 1 Then
  445.          c.Text = "12"
  446.       Else
  447.          c.Text = Val(c.Text) - 1
  448.       End If
  449.    Case "m"
  450.       If CurVal% = 0 Then
  451.          c.Text = "59"
  452.       Else
  453.          c.Text = Format$(Val(c.Text) - 1, "00")
  454.       End If
  455.    Case "s"
  456.       If CurVal% = 0 Then
  457.          c.Text = "59"
  458.       Else
  459.          c.Text = Format$(Val(c.Text) - 1, "00")
  460.       End If
  461.    Case "a"
  462.       FlipFlopTAMPM
  463.    Case "n"
  464.       If CurVal% = 1 Then
  465.          c.Text = "12"
  466.       Else
  467.          c.Text = Format$(Val(c.Text) - 1, "00")
  468.       End If
  469.    Case "d"
  470.       If CurVal% = 1 Then
  471.          c.Text = "31"
  472.       Else
  473.          c.Text = Format$(Val(c.Text) - 1, "00")
  474.       End If
  475.    Case "y"
  476.       If CurVal% = 1 Then
  477.          c.Text = "2050"
  478.       Else
  479.          c.Text = Format$(Val(c.Text) - 1, "0000")
  480.       End If
  481. End Select
  482. 'c.Text = Val(c.Text) - 1
  483. End Sub
  484. Sub MoveUp (c As Control)
  485. Dim CurVal As Integer
  486. CurVal% = Val(c.Text)
  487. Select Case c.Tag
  488.    Case "h"
  489.       If CurVal% = 11 Then
  490.          FlipFlopTAMPM
  491.       End If
  492.       If CurVal% = 12 Then
  493.          c.Text = "1"
  494.       Else
  495.          c.Text = Val(c.Text) + 1
  496.       End If
  497.    Case "m"
  498.       If CurVal% = 59 Then
  499.          c.Text = "00"
  500.       Else
  501.          c.Text = Format$(Val(c.Text) + 1, "00")
  502.       End If
  503.    Case "s"
  504.       If CurVal% = 59 Then
  505.          c.Text = "00"
  506.       Else
  507.          c.Text = Format$(Val(c.Text) + 1, "00")
  508.       End If
  509.    Case "a"
  510.       FlipFlopTAMPM
  511.    Case "n"
  512.       If CurVal% = 12 Then
  513.          c.Text = "01"
  514.       Else
  515.          c.Text = Format$(Val(c.Text) + 1, "00")
  516.       End If
  517.    Case "d"
  518.       If CurVal% = 31 Then
  519.          c.Text = "01"
  520.       Else
  521.          c.Text = Format$(Val(c.Text) + 1, "00")
  522.       End If
  523.    Case "y"
  524.       If CurVal% = 2050 Then
  525.          c.Text = "1980"
  526.       Else
  527.          c.Text = Format$(Val(c.Text) + 1, "0000")
  528.       End If
  529. End Select
  530. End Sub
  531. Sub SpinButton_DblClick (Index As Integer)
  532. If (Index = 1) And (Active$ <> "n") And (Active$ <> "d") And (Active$ <> "y") Then
  533.    tMonth.SetFocus
  534. End If
  535. If (Index = 0) And (Active$ <> "h") And (Active$ <> "m") And (Active$ <> "s") And (Active$ <> "a") Then
  536.    tHour.SetFocus
  537. End If
  538. If LastDirection$ = "u" Then
  539.    Select Case Active$
  540.      Case "n"
  541.         Call MoveUp(tMonth)
  542.      Case "d"
  543.         Call MoveUp(tDay)
  544.      Case "y"
  545.         Call MoveUp(tYear)
  546.      Case "h"
  547.         Call MoveUp(tHour)
  548.      Case "m"
  549.         Call MoveUp(tMinute)
  550.      Case "s"
  551.         Call MoveUp(tSecond)
  552.      Case "a"
  553.         Call MoveUp(tAMPM)
  554.    End Select
  555.    Select Case Active$
  556.      Case "n"
  557.         Call MoveDown(tMonth)
  558.      Case "d"
  559.         Call MoveDown(tDay)
  560.      Case "y"
  561.         Call MoveDown(tYear)
  562.      Case "h"
  563.         Call MoveDown(tHour)
  564.      Case "m"
  565.         Call MoveDown(tMinute)
  566.      Case "s"
  567.         Call MoveDown(tSecond)
  568.      Case "a"
  569.         Call MoveDown(tAMPM)
  570.    End Select
  571. End If
  572. SpinButton(Index).SetFocus
  573. End Sub
  574. Sub SpinButton_GotFocus (Index As Integer)
  575. If (Index = 1) And (Active$ <> "n") And (Active$ <> "d") And (Active$ <> "y") Then
  576.    tMonth.SetFocus
  577.    Exit Sub
  578. End If
  579. If (Index = 0) And (Active$ <> "h") And (Active$ <> "m") And (Active$ <> "s") And (Active$ <> "a") Then
  580.    tHour.SetFocus
  581.    Exit Sub
  582. End If
  583.    Select Case Active$
  584.      Case "n"
  585.         tMonth.SetFocus
  586.      Case "d"
  587.         tDay.SetFocus
  588.      Case "y"
  589.         tYear.SetFocus
  590.      Case "h"
  591.         tHour.SetFocus
  592.      Case "m"
  593.         tMinute.SetFocus
  594.      Case "s"
  595.         tSecond.SetFocus
  596.      Case "a"
  597.         tAMPM.SetFocus
  598.    End Select
  599. End Sub
  600. Sub SpinButton_MouseDown (Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
  601. Const VK_LBUTTON = &H1
  602. Const TIME_DELAY = 180      ' Time delay between Spin Button Events
  603. Dim dwEvent As Long
  604. LastY = Y
  605. ' Make sure that the Spin Button Event occurs at least once
  606. dwEvent = GetTickCount() - TIME_DELAY
  607. SpinIt:
  608.    ' Do this while the user holds down the left mouse button
  609.    Do While (GetAsyncKeyState(VK_LBUTTON) And &H8000) = -32768
  610.         ' Break out of the loop if we haven't waited long enough
  611.         If dwEvent + TIME_DELAY > GetTickCount() Then GoTo Break:
  612.         ' If the user wants to increment the counter
  613.         If Y > (SpinButton(Index).Height \ 2) Then
  614.             SpinButton(Index).Picture = d.Picture  ' Set Picture to Up
  615.             If Index = 1 Then
  616.             Select Case Active$
  617.                Case "n"
  618.                    Call MoveDown(tMonth)
  619.                Case "d"
  620.                    Call MoveDown(tDay)
  621.                Case "y"
  622.                    Call MoveDown(tYear)
  623.             End Select
  624.             End If
  625.             If Index = 0 Then
  626.             Select Case Active$
  627.                Case "h"
  628.                    Call MoveDown(tHour)
  629.                Case "s"
  630.                    Call MoveDown(tSecond)
  631.                Case "m"
  632.                    Call MoveDown(tMinute)
  633.                Case "a"
  634.                    Call MoveDown(tAMPM)
  635.             End Select
  636.             End If
  637.             LastDirection$ = "d"
  638.         End If
  639.         ' If the user wants to decrement the counter
  640.         If Y < (SpinButton(Index).Height \ 2) Then
  641.             SpinButton(Index).Picture = u.Picture   ' Set Picture to Down
  642.             If Index = 1 Then
  643.             Select Case Active$
  644.                Case "n"
  645.                    Call MoveUp(tMonth)
  646.                Case "d"
  647.                    Call MoveUp(tDay)
  648.                Case "y"
  649.                    Call MoveUp(tYear)
  650.             End Select
  651.             End If
  652.             If Index = 0 Then
  653.             Select Case Active$
  654.                Case "h"
  655.                    Call MoveUp(tHour)
  656.                Case "s"
  657.                    Call MoveUp(tSecond)
  658.                Case "m"
  659.                    Call MoveUp(tMinute)
  660.                Case "a"
  661.                    Call MoveUp(tAMPM)
  662.             End Select
  663.             End If
  664.             LastDirection$ = "u"
  665.         End If
  666.         ' Save the last time the Spin Button was active
  667.         dwEvent = GetTickCount()
  668.     Loop
  669.     ' Set the Picture to Normal
  670.     SpinButton(Index).Picture = N.Picture
  671.     If Index = 1 Then
  672.     Select Case Active$
  673.        Case "n"
  674.           tMonth.SetFocus
  675.        Case "d"
  676.           tDay.SetFocus
  677.        Case "y"
  678.           tYear.SetFocus
  679.     End Select
  680.     End If
  681.     If Index = 0 Then
  682.     Select Case Active$
  683.        Case "h"
  684.           tHour.SetFocus
  685.        Case "m"
  686.           tMinute.SetFocus
  687.        Case "s"
  688.           tSecond.SetFocus
  689.        Case "a"
  690.           tAMPM.SetFocus
  691.     End Select
  692.     End If
  693.     DoEvents
  694.     Exit Sub
  695. Break:
  696.     GoTo SpinIt:
  697. End Sub
  698. Sub tAMPM_GotFocus ()
  699. tAMPM.SelStart = 0
  700. tAMPM.SelLength = 2
  701. Active$ = "a"
  702. End Sub
  703. Sub tAMPM_KeyPress (KeyAscii As Integer)
  704. If KeyAscii >= 32 Then
  705.    FlipFlopTAMPM
  706.    KeyAscii = 0
  707.    tAMPM.SelStart = 0
  708.    tAMPM.SelLength = 2
  709. End If
  710. End Sub
  711. Sub tAMPM_LostFocus ()
  712. If tAMPM.Text <> "am" And tAMPM.Text <> "pm" Then
  713.    tAMPM.Text = "am"
  714. End If
  715. End Sub
  716. Sub tDay_GotFocus ()
  717. tDay.SelStart = 0
  718. tDay.SelLength = 2
  719. Active$ = "d"
  720. End Sub
  721. Sub tDay_KeyPress (KeyAscii As Integer)
  722. If KeyAscii >= 32 Then
  723.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  724. End If
  725. End Sub
  726. Sub tDay_LostFocus ()
  727. tVal = Val(tDay.Text)
  728. If tVal < 1 Or tVal > 31 Then
  729.    tVal = 1
  730. End If
  731. tDay.Text = Format$(tVal, "00")
  732. End Sub
  733. Sub tHour_GotFocus ()
  734. tHour.SelStart = 0
  735. tHour.SelLength = 2
  736. Active$ = "h"
  737. End Sub
  738. Sub tHour_KeyPress (KeyAscii As Integer)
  739. If KeyAscii >= 32 Then
  740.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  741. End If
  742. End Sub
  743. Sub tHour_LostFocus ()
  744. tVal = Val(tHour.Text)
  745. If tVal < 1 Or tVal > 12 Then
  746.    tVal = 12
  747. End If
  748. tHour.Text = Format$(tVal, "0")
  749. End Sub
  750. Sub tMinute_GotFocus ()
  751. tMinute.SelStart = 0
  752. tMinute.SelLength = 2
  753. Active$ = "m"
  754. End Sub
  755. Sub tMinute_KeyPress (KeyAscii As Integer)
  756. If KeyAscii >= 32 Then
  757.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  758. End If
  759. End Sub
  760. Sub tMinute_LostFocus ()
  761. tVal = Val(tMinute.Text)
  762. If tVal <= 0 Or tVal > 59 Then
  763.    tVal = 0
  764. End If
  765. tMinute.Text = Format$(tVal, "00")
  766. End Sub
  767. Sub tMonth_GotFocus ()
  768. tMonth.SelStart = 0
  769. tMonth.SelLength = 2
  770. Active$ = "n"
  771. End Sub
  772. Sub tMonth_KeyPress (KeyAscii As Integer)
  773. If KeyAscii >= 32 Then
  774.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  775. End If
  776. End Sub
  777. Sub tMonth_LostFocus ()
  778. tVal = Val(tMonth.Text)
  779. If tVal < 1 Or tVal > 12 Then
  780.    tVal = 12
  781. End If
  782. tMonth.Text = Format$(tVal, "00")
  783. End Sub
  784. Sub tSecond_GotFocus ()
  785. tSecond.SelStart = 0
  786. tSecond.SelLength = 2
  787. Active$ = "s"
  788. End Sub
  789. Sub tSecond_KeyPress (KeyAscii As Integer)
  790. If KeyAscii >= 32 Then
  791.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  792. End If
  793. End Sub
  794. Sub tSecond_LostFocus ()
  795. tVal = Val(tSecond.Text)
  796. If tVal <= 0 Or tVal > 59 Then
  797.    tVal = 0
  798. End If
  799. tSecond.Text = Format$(tVal, "00")
  800. End Sub
  801. Sub tYear_GotFocus ()
  802. tYear.SelStart = 0
  803. tYear.SelLength = 4
  804. Active$ = "y"
  805. End Sub
  806. Sub tYear_KeyPress (KeyAscii As Integer)
  807. If KeyAscii >= 32 Then
  808.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  809. End If
  810. End Sub
  811. Sub tYear_LostFocus ()
  812. tVal = Val(tYear.Text)
  813. If tVal < 100 Then tVal = tVal + 1900
  814. If tVal < 1980 Or tVal > 2050 Then
  815.    tVal = 1980
  816. End If
  817. tYear.Text = Format$(tVal, "0000")
  818. End Sub
  819.